<?php

namespace App\Http\Controllers\Merchant;

use App\Http\Response;
use App\WalletConfig;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class WalletConfigController extends Controller
{
    use Response;
    protected $mch_id;
    public function __construct()
    {
        $this->mch_id=auth('merchant')->id();
    }

    public function index()
    {

        $data=WalletConfig::where('mch_id',$this->mch_id)->first();
        return $this->success(200,$data);
    }
    public function store(Request $request)
    {

        $data=$request->all();
        $data['mch_id']=$this->mch_id;
        $created=WalletConfig::create($data);
        if ($created){
            return $this->message(200,trans('topic.create success'));
        }else{
            return $this->error(505,trans('topic.create failed'));
        }
    }
    public function update(Request $request)
    {
        $data=$request->all();
        $update=WalletConfig::where('mch_id',auth('merchant')->id())->update($data);
        if ($update){
            return $this->message(200,trans('topic.update success'));
        }else{
            return $this->error(505,trans('topic.update failed'));
        }
    }
}
